﻿namespace TriangleGames.TrainRes
{
    using System;
    using UnityEngine;

    [Serializable]
    public class LayoutOption
    {
        public FsmBool boolParam;
        public FsmFloat floatParam;
        public LayoutOptionType option;

        public LayoutOption()
        {
            this.ResetParameters();
        }

        public LayoutOption(LayoutOption source)
        {
            this.option = source.option;
            this.floatParam = new FsmFloat(source.floatParam);
            this.boolParam = new FsmBool(source.boolParam);
        }

        public GUILayoutOption GetGUILayoutOption()
        {
            switch (this.option)
            {
                case LayoutOptionType.Width:
                    return GUILayout.Width(this.floatParam.Value);

                case LayoutOptionType.Height:
                    return GUILayout.Height(this.floatParam.Value);

                case LayoutOptionType.MinWidth:
                    return GUILayout.MinWidth(this.floatParam.Value);

                case LayoutOptionType.MaxWidth:
                    return GUILayout.MaxWidth(this.floatParam.Value);

                case LayoutOptionType.MinHeight:
                    return GUILayout.MinHeight(this.floatParam.Value);

                case LayoutOptionType.MaxHeight:
                    return GUILayout.MaxHeight(this.floatParam.Value);

                case LayoutOptionType.ExpandWidth:
                    return GUILayout.ExpandWidth(this.boolParam.Value);

                case LayoutOptionType.ExpandHeight:
                    return GUILayout.ExpandHeight(this.boolParam.Value);
            }
            return null;
        }

        public void ResetParameters()
        {
            this.floatParam = 0f;
            this.boolParam = false;
        }

        public enum LayoutOptionType
        {
            Width,
            Height,
            MinWidth,
            MaxWidth,
            MinHeight,
            MaxHeight,
            ExpandWidth,
            ExpandHeight
        }
    }
}

